using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class AccRightMap : EntityTypeConfiguration<AccRight>
    {
        public AccRightMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("AccRight");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.UTypeID).HasColumnName("UTypeID");
            this.Property(t => t.Function).HasColumnName("Function");
            this.Property(t => t.AccessType).HasColumnName("AccessType");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");

            // Relationships
            this.HasOptional(t => t.Function1)
                .WithMany(t => t.AccRights)
                .HasForeignKey(d => d.Function);
            this.HasOptional(t => t.UserType)
                .WithMany(t => t.AccRights)
                .HasForeignKey(d => d.UTypeID);

        }
    }
}
